﻿using Kingdee.BOS;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Contracts.Report;
using Kingdee.BOS.Core.Report;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using RK.Tools;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Kingdee.BOS.Core.Enums.BOSEnums;

namespace RK.ReportPlugin.BPW
{
    [Description("BPW_简单账表：BPW采购件库存查询"), HotUpdate]
    public class CGJReport : SysReportBaseService
    {
        public override void Initialize()
        {
            base.Initialize();
            this.ReportProperty.ReportType = ReportType.REPORTTYPE_NORMAL;
            this.ReportProperty.ReportName = new LocaleValue("采购件库存查询", base.Context.UserLocale.LCID);
            this.IsCreateTempTableByPlugin = true;
            this.ReportProperty.IsUIDesignerColumns = false;
            this.ReportProperty.IsGroupSummary = true;
            this.ReportProperty.SimpleAllCols = false;
            this.ReportProperty.PrimaryKeyFieldName = "MATNAME";
            this.ReportProperty.IdentityFieldName = "FIDENTITYID";
        }
        public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
        {
            string cgy = KingdeeTools.GetCreator(this.Context, (int)this.Context.UserId);
            List<SqlParam> sqlParams = new List<SqlParam>();
            sqlParams.Add(new SqlParam("@TempName", KDDbType.AnsiString, tableName));
            sqlParams.Add(new SqlParam("@CGY", KDDbType.AnsiString, cgy));
            DBUtils.ExecuteStoreProcedure(this.Context, "P_ZSLH_CGJReport", sqlParams);
        }
        public override ReportHeader GetReportHeaders(IRptParams filter)
        {
            ReportHeader header = new ReportHeader();
            header.AddChild("MATNAME", new LocaleValue("物料名称"), SqlStorageType.Sqlnvarchar, visible: true);
            header.AddChild("F_XRIS_LJTH", new LocaleValue("零件图号"), SqlStorageType.Sqlnvarchar, visible: true);
            header.AddChild("F_XRIS_TH1", new LocaleValue("在制图号1"), SqlStorageType.Sqlnvarchar, visible: true);
            header.AddChild("F_XRIS_TH2", new LocaleValue("在制图号2"), SqlStorageType.Sqlnvarchar, visible: true);
            header.AddChild("F_XRIS_ZCTH", new LocaleValue("总成图号"), SqlStorageType.Sqlnvarchar, visible: true);
            header.AddChild("待检仓", new LocaleValue("待检仓", 2052), SqlStorageType.SqlDecimal, visible: true);
            header.AddChild("材料仓", new LocaleValue("材料仓", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("配件仓", new LocaleValue("配件仓", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("售后仓", new LocaleValue("售后仓", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("出口仓", new LocaleValue("出口仓", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("嘉资仓", new LocaleValue("嘉资仓", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("庆达仓", new LocaleValue("庆达仓", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("钧耀仓", new LocaleValue("钧耀仓", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("总装车间仓", new LocaleValue("总装车间仓", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("焊接车间仓", new LocaleValue("焊接车间仓", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("机加工车间仓", new LocaleValue("机加工车间仓", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("自动调整臂车间仓", new LocaleValue("自动调整臂车间仓", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("电泳车间仓", new LocaleValue("电泳车间仓", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("小计含车间", new LocaleValue("小计含车间", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("小计不含车间", new LocaleValue("小计不含车间", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("剩余收料数量", new LocaleValue("剩余收料数量", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("合计不含车间", new LocaleValue("合计不含车间", 2052), SqlStorageType.SqlDecimal);
            header.AddChild("出口需求", new LocaleValue("出口需求", 2052), SqlStorageType.SqlDecimal);
            return header;
        }
        public override List<Kingdee.BOS.Core.Report.SummaryField> GetSummaryColumnInfo(IRptParams filter)
        {
            var result = base.GetSummaryColumnInfo(filter);
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("待检仓", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("材料仓", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("配件仓", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("售后仓", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("出口仓", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("嘉资仓", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("庆达仓", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("钧耀仓", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("总装车间仓", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("焊接车间仓", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("机加工车间仓", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("自动调整臂车间仓", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("电泳车间仓", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("小计含车间", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("小计不含车间", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("剩余收料数量", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("合计不含车间", Enu_SummaryType.SUM));
            result.Add(new Kingdee.BOS.Core.Report.SummaryField("出口需求", Enu_SummaryType.SUM));
            return result;
        }
    }
}
